<template>
  <div class="list-component">
    <el-card shadow="hover">
      <template #header v-if="datas.showHeader">
        <div class="list-header">
          <span>{{ datas.headerText }}</span>
        </div>
      </template>
      
      <div class="list-content">
        <div 
          v-for="(item, index) in datas.items" 
          :key="index" 
          class="list-item"
          :class="{ 'border-bottom': index !== datas.items.length - 1 && datas.border, 'stripe': datas.stripe && index % 2 === 1 }"
        >
          <div class="list-item-content">
            <el-avatar v-if="datas.showAvatar" :src="item.avatar || defaultAvatar" :size="40"></el-avatar>
            <div class="list-item-text">
              <div class="list-item-title">{{ item.title }}</div>
              <div class="list-item-description">{{ item.description }}</div>
            </div>
          </div>
          
          <div v-if="datas.showActions" class="list-item-actions">
            <el-button 
              v-for="(action, aIndex) in datas.actions" 
              :key="aIndex"
              type="text"
              size="small"
            >{{ action }}</el-button>
          </div>
        </div>
      </div>
    </el-card>

  </div>
</template>

<script>
export default {
  name: 'list',
  props: {
    datas: {
      type: Object,
      required: true
    },
  },
  data() {
    return {
      defaultAvatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
    }
  }
}
</script>

<style scoped lang="less">
.list-component {
  position: relative;
  width: 100%;
  height: 100%;
  
  .list-header {
    font-weight: bold;
    font-size: 16px;
  }
  
  .list-content {
    .list-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 12px 0;
      
      &.border-bottom {
        border-bottom: 1px solid #ebeef5;
      }
      
      &.stripe {
        background-color: #fafafa;
      }
      
      .list-item-content {
        display: flex;
        align-items: center;
        
        .el-avatar {
          margin-right: 12px;
        }
        
        .list-item-text {
          .list-item-title {
            font-size: 14px;
            color: #303133;
            margin-bottom: 4px;
          }
          
          .list-item-description {
            font-size: 12px;
            color: #909399;
          }
        }
      }
      
      .list-item-actions {
        .el-button {
          margin-left: 10px;
        }
      }
    }
  }
}
</style> 